﻿using System.Configuration;

namespace Module.Common.Common
{
    /// <summary>
    /// 全局数据，系统基础数据
    /// </summary>
    public static class GlobalData
    {
        /// <summary>
        /// 黑方（false代表黑方)
        /// </summary>
        public const bool BLACKSIDE = false;  // 黑方
        /// <summary>
        /// 红方（true代表红方）
        /// </summary>
        public const bool REDSIDE = true;  //红方
        private static readonly double[] QiPanGrid_X = new double[9]  // 棋盘每一格的列坐标
        {
            10.0, 78.0, 146.0, 213.0, 281.0, 348.0, 415.0, 483.0, 551.0
        };
        private static readonly double[] QiPanGrid_Y = new double[10]  // 棋盘每一格的行坐标
        {
            9.0, 77.0, 144.0, 211.0, 279.0, 347.0, 414.0, 482.0, 550.0, 618.0
        };
        private static readonly string[] qiZiImageFileName = {  // 棋子编号0-31，分别对应的图像文件名
            "黑将", "黑士", "黑士", "黑象", "黑象", "黑马", "黑马", "黑车", "黑车", "黑炮", "黑炮", "黑卒", "黑卒", "黑卒", "黑卒", "黑卒",
            "红帅", "红仕", "红仕", "红相", "红相", "红马", "红马", "红车", "红车", "红炮", "红炮", "红兵", "红兵", "红兵", "红兵", "红兵"
        };
        private static readonly string[] qiZiCnName = {  // 棋子的中文简称，用于棋谱翻译
            "将", "士", "士", "象", "象", "马", "马", "车", "车", "炮", "炮", "卒", "卒", "卒", "卒", "卒",
            "帅", "仕", "仕", "相", "相", "马", "马", "车", "车", "炮", "炮", "兵", "兵", "兵", "兵", "兵"
        };

        /// <summary>
        /// 获取棋盘每一格的列坐标，共9列
        /// </summary>
        /// <param name="x">列号（0-8）</param>
        /// <returns></returns>
        public static double GetQiPanGrid_X(int x) => (x is >= 0 and < 9) ? QiPanGrid_X[x] : -1;

        /// <summary>
        /// 获取棋盘每一格的行坐标，共10行
        /// </summary>
        /// <param name="y">行号（0-9）</param>
        /// <returns></returns>
        public static double GetQiPanGrid_Y(int y) => (y is >= 0 and < 10) ? QiPanGrid_Y[y] : -1;

        /// <summary>
        /// 获取棋子图像的文件名（不含扩展名），共32个
        /// </summary>
        /// <param name="id">棋子编号（0-31）</param>
        /// <returns></returns>
        public static string QiZiImageFileName(int id) => (id is >= 0 and < 32) ? qiZiImageFileName[id] : "";

        /// <summary>
        /// 获取棋子的中文名，共32个
        /// </summary>
        /// <param name="id">棋子编号（0-31）</param>
        /// <returns></returns>
        public static string QiZiCnName(int id) => (id is >= 0 and < 32) ? qiZiCnName[id] : "";
    }
}
